package org.outlook.common.date;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;

import org.outlook.common.date.OutlookDateFormat;


public class DateUtil {

	public static Date converToDate(String date, DateFormat df) {
		try {
			return df.parse(date);
		} catch (ParseException e) {
			return null;
		}
	}
	
	public static Date converToDate(String date, DateFormat[] dateFormats) {
		for (DateFormat df : dateFormats)
			try {
				if(df instanceof OutlookDateFormat) {
					OutlookDateFormat dataFormat = (OutlookDateFormat) df;
					return dataFormat.parse(date);
				}
				Date d = df.parse(date);
				if(d != null)
					return d;
			} catch (ParseException e) {
				e.printStackTrace();
			}
		return null;
	}
}
